test: Add type tests covering di.get and SQSService#1198
Merged
Conversation
corinja
approved these changes
Mar 25, 2024
Member
corinja
left a comment
There was a problem hiding this comment.
I think this looks good. It will probably take me actually using it in some development using the Lambda Wrapper to really get the benefits but I think it looks good.
Merged
|
🎉 This PR is included in version 2.0.0-beta.16 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First attempt at adding tests for some of the types used in Lambda Wrapper v2.
In #1196 I tried to fix one problem and inadvertently caused another more serious problem. I caught this during manual QA, but this is precisely why automated tests are so valuable. Some of the type-related features of Lambda Wrapper are complex enough that we should have their behaviour defined in a test suite.
About these tests: they do not "run", as such, and instead the types are checked statically by the TypeScript compiler. All assertions happen at the type system level. Test failures will be flagged by a type error on the failing assertion. I think it still makes sense to organise these tests using
describeanditto give structure and context to the assertions.The docs for expect-type are useful. I tried various packages (
ts-expect,tsd) and foundexpect-typeto provide the most expressive API and it doesn't need any particular setup.So far I've written tests for only
di.getandSQSService, as this covers most of the interesting stuff and is where I've been seeing problems – there's enough here to fail following the changes in #1196. It would also be good to cover things relating to Lambda Wrapper configuration, however this was not as straightforward as I hoped so I'm leaving it for now.Jira: ENG-3188